/*
 ============================================================================
 Name        : Set_CGI.c
 Author      : liuzhanchun
 Version     :
 Copyright   : Your copyright notice
 Description : Hello World in C, Ansi-style
 ============================================================================
 */

#if 1
#define SERVER_NAME cgiServerName
#endif
#if 0
#define SERVER_NAME "www.boutell.com"
#endif

/* You may need to change this, particularly under Windows;
	it is a reasonable guess as to an acceptable place to
	store a saved environment in order to test that feature.
	If that feature is not important to you, you needn't
	concern yourself with this. */

#ifdef WIN32
#define SAVED_ENVIRONMENT "c:\\cgicsave.env"
#else
#define SAVED_ENVIRONMENT "/tmp/cgicsave.env"
#endif /* WIN32 */

#include <stdio.h>
#include "cgic.h"
#include <string.h>
#include <stdlib.h>
#include "config_ini.h"

int cgiMain() {
    /*从html获取数据，设置cookie*/
	/*网络设置*/
    char local_ip[32] = {0};
    configFileStrGet("/boa/my.ini","local_ip",local_ip,32);
	fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","local_ip",local_ip);

	char local_gateway[32] = {0};
    configFileStrGet("/boa/my.ini","local_gateway",local_gateway,32);
	fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","local_gateway",local_gateway);

	
	char local_mask[32] = {0};
    configFileStrGet("/boa/my.ini","local_mask",local_mask,32);
	fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","local_mask",local_mask);


    char remote_ip[32] = {0};
    configFileStrGet("/boa/my.ini","remote_ip",remote_ip,32);
    fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","remote_ip",remote_ip);


	char remote_port[32] = {0};
    configFileStrGet("/boa/my.ini","remote_port",remote_port,32);
    fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","remote_port",remote_port);

	/*系统管理*/
	char user_name[32] = {0};
    configFileStrGet("/boa/my.ini","user_name",user_name,32);
	fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","user_name",user_name);

	char user_password[32] = {0};
    configFileStrGet("/boa/my.ini","user_password",user_password,32);
	fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","user_password",user_password);
	
	char language[32] = {0};
    configFileStrGet("/boa/my.ini","language",language,32);
    fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","language",language);

	//datetimes

	char maintenance[32] = {0};
    configFileStrGet("/boa/my.ini","maintenance",maintenance,32);
    fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","maintenance",maintenance);
	
	char mon[16] = {0};
	configFileStrGet("/boa/my.ini","mon",mon,16);
	fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","mon",mon);

	char tues[16] = {0};
	configFileStrGet("/boa/my.ini","tues",tues,16);
	fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","tues",tues);

	char wed[16] = {0};
	configFileStrGet("/boa/my.ini","wed",wed,16);
	fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","wed",wed);

	char thurs[16] = {0};
	configFileStrGet("/boa/my.ini","thurs",thurs,16);
	fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","thurs",thurs);

	char fri[16] = {0};
	configFileStrGet("/boa/my.ini","fri",fri,16);
	fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","fri",fri);

	char sat[16] = {0};
	configFileStrGet("/boa/my.ini","sat",sat,16);
	fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","sat",sat);

	char sun[16] = {0};
	configFileStrGet("/boa/my.ini","sun",sun,16);
	fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","sun",sun);

	char rebootTimeSelect[16] = {0};
	configFileStrGet("/boa/my.ini","rebootTimeSelect",rebootTimeSelect,16);
	fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","rebootTimeSelect",rebootTimeSelect);
	//shengji

	//version
	char equipment_mode[32] = {0};
    configFileStrGet("/boa/my.ini","equipment_mode",equipment_mode,32);
    fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","equipment_mode",equipment_mode);

	char equipment_serial_number[32] = {0};
    configFileStrGet("/boa/my.ini","equipment_serial_number",equipment_serial_number,32);
    fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","equipment_serial_number",equipment_serial_number);

	char fpga_version[32] = {0};
    configFileStrGet("/boa/my.ini","fpga_version",fpga_version,32);
    fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","fpga_version",fpga_version);

	char arm_version[32] = {0};
    configFileStrGet("/boa/my.ini","arm_version",arm_version,32);
    fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","arm_version",arm_version);

	char web_version[32] = {0};
    configFileStrGet("/boa/my.ini","web_version",web_version,32);
    fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","web_version",web_version);

	//==============像机设置===================
	char camera_line_number[32] = {0};
	configFileStrGet("/boa/my.ini","camera_line_number",camera_line_number,32);
    fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","camera_line_number",camera_line_number);

	char whitebalance[32] = {0};
	configFileStrGet("/boa/my.ini","whitebalance",whitebalance,32);
    fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","whitebalance",whitebalance);

	char camera_fusion_degree[32] = {0};
	configFileStrGet("/boa/my.ini","camera_fusion_degree",camera_fusion_degree,32);
    fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","camera_fusion_degree",camera_fusion_degree);

	char camera_brightness[32] = {0};
	configFileStrGet("/boa/my.ini","camera_brightness",camera_brightness,32);
    fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","camera_brightness",camera_brightness);

	char camera_delay[32] = {0};
	configFileStrGet("/boa/my.ini","camera_delay",camera_delay,32);
    fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","camera_delay",camera_delay);

	char triggerinput_1[32] = {0};
	configFileStrGet("/boa/my.ini","triggerinput_1",triggerinput_1,32);
    fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","triggerinput_1",triggerinput_1);

	char triggerinput_2[32] = {0};
	configFileStrGet("/boa/my.ini","triggerinput_2",triggerinput_2,32);
    fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","triggerinput_2",triggerinput_2);

	char marking_setting[32] = {0};
	configFileStrGet("/boa/my.ini","marking_setting",marking_setting,32);
    fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","marking_setting",marking_setting);

	char marking_number[32] = {0};
	configFileStrGet("/boa/my.ini","marking_number",marking_number,32);
    fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","marking_number",marking_number);

	char camera_HDMI_display_switch[32] = {0};
	configFileStrGet("/boa/my.ini","camera_HDMI_display_switch",camera_HDMI_display_switch,32);
    fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","camera_HDMI_display_switch",camera_HDMI_display_switch);


	char camera_HDMI_display[32] = {0};
	configFileStrGet("/boa/my.ini","camera_HDMI_display",camera_HDMI_display,32);
    fprintf(cgiOut,"Set-Cookie: %s=%s;  path=/\r\n","camera_HDMI_display",camera_HDMI_display);






	//存储设置...

	/**/

	/* Send the content type, letting the browser know this is HTML */
	cgiHeaderContentType("text/html; charset=UTF-8");


	/* Send the content type, letting the browser know this is HTML */
	cgiHeaderContentType("text/html; charset=UTF-8");

	/* Top of the page */
	fprintf(cgiOut, "<HTML><HEAD>\n");
	fprintf(cgiOut, "<TITLE>web 管理</TITLE></HEAD>\n");
	fprintf(cgiOut, "<BODY><H1></H1>\n");

	//刷新页面
	fprintf(cgiOut, "<meta http-equiv=Refresh content=0;URL=../manager.html\n");
	fprintf(cgiOut, "</BODY></HTML>\n");

	return 0;
}

